/* Turska Framework/UI library (Turs2)
 * Copyright 2003-2009 Jetro Lauha
 * All rights reserved.
 * Web: http://iki.fi/jetro/turska/
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of EITHER:
 *   (1) The GNU Lesser General Public License as published by the Free
 *       Software Foundation; either version 2.1 of the License, or (at
 *       your option) any later version. The text of the GNU Lesser
 *       General Public License is included with this library in the
 *       file LICENSE-LGPL.txt.
 *   (2) The BSD-style license that is included with this library in
 *       the file LICENSE-BSD.txt.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files
 * LICENSE-LGPL.txt and LICENSE-BSD.txt for more details.
 *
 * $Id: T2IMGUIImageSliderStyle.h 131 2009-06-05 05:58:05Z jlauha $
 * $Revision: 131 $
 */

#ifndef T2IMGUIIMAGESLIDERSTYLE_H_INCL
#define T2IMGUIIMAGESLIDERSTYLE_H_INCL


namespace turska
{
    //! Image slider with fixed extents defined by the image size.
    /*! The width and height are ignored when there's an image to use.
     * \note This implementation assumes that a single image slider style
     *       object is exclusively used only for either horizontal or
     *       vertical sliders. Images matching the intended axis should be
     *       given on constructor. If you want to use both horizontal and
     *       vertical sliders, simply create separate style objects for them.
     */
    class IMGUIImageSliderStyle : public IMGUISliderStyle
    {
    public:
        IMGUIImageSliderStyle(Image *imageDefault, Image *imageHot,
                              Image *imageActive, Image *imageHotActive,
                              Image *thumbImageDefault, Image *thumbImageHot,
                              Image *thumbImageActive, Image *thumbImageHotActive);

        virtual bool isKeyFocusAllowed() { return mKeyFocusAllowed; }

        virtual bool isInside(const IMGUI &imgui, REAL x, REAL y,
                              const Rectangle &rect);

        virtual void getIntModifierMultipliers(I32 &shift, I32 &control);
        virtual void getRealModifierMultipliers(REAL &shift, REAL &control);

        virtual I32 getIntValue(const IMGUI &imgui, IMGUI_WIDGET_ORIENTATION axis,
                                I32 minValue, I32 maxValue,
                                REAL x, REAL y, const Rectangle &area);
        virtual REAL getRealValue(const IMGUI &imgui, IMGUI_WIDGET_ORIENTATION axis,
                                  REAL minValue, REAL maxValue,
                                  REAL x, REAL y, const Rectangle &area);

        virtual Rectangle render(const IMGUI &imgui, I32 widgetState,
                                 IMGUI_WIDGET_ORIENTATION axis,
                                 I32 value, I32 minValue, I32 maxValue,
                                 REAL x, REAL y, REAL width, REAL height);
        virtual Rectangle render(const IMGUI &imgui, I32 widgetState,
                                 IMGUI_WIDGET_ORIENTATION axis,
                                 REAL value, REAL minValue, REAL maxValue,
                                 REAL x, REAL y, REAL width, REAL height);

        // Local
        void setScale(REAL scale) { mScale = scale; }
        void setSliderColor(const Color &color) { mSliderColor = color; }
        void setThumbColor(const Color &color) { mThumbColor = color; }

        void setKeyFocusAllowed(bool allowed) { mKeyFocusAllowed = allowed; }

        REAL getWidth() { return mScale * mImageWidth; }
        REAL getHeight() { return mScale * mImageHeight; }

    protected:

        Rectangle render(const IMGUI &imgui, I32 widgetState, IMGUI_WIDGET_ORIENTATION axis,
                         REAL normalizedValue, REAL x, REAL y, REAL width, REAL height);

        REAL mScale;
        Color mSliderColor;
        Color mThumbColor;
        Image *mSliderImages[IMGUI_WS_COUNT];
        Image *mThumbImages[IMGUI_WS_COUNT];
        UI32 mImageWidth, mImageHeight;
        UI32 mThumbImageWidth, mThumbImageHeight;
        bool mKeyFocusAllowed;
    };

} // namespace turska


#endif // !T2IMGUIIMAGESLIDERSTYLE_H_INCL
